package xin.marcher.wind.process.platform;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;

import java.util.ArrayList;

/**
 * 业务线流程编排注册器
 */
@Slf4j
public class BizProcessArrangeRegistrar implements ImportBeanDefinitionRegistrar {

    @Override
    public void registerBeanDefinitions(AnnotationMetadata annotationMetadata, BeanDefinitionRegistry beanDefinitionRegistry) {
        try {
            // 注册 BizProcessArrangeContextFactory
            BeanDefinitionBuilder bdb = BeanDefinitionBuilder.rootBeanDefinition(BizProcessArrangeContextFactory.class);
            bdb.addConstructorArgValue(new ArrayList<>());
            bdb.addConstructorArgReference("springBeanInstanceCreator");
            bdb.addConstructorArgReference("processStateStore");
            beanDefinitionRegistry.registerBeanDefinition(BizProcessArrangeContextFactory.class.getName(), bdb.getBeanDefinition());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
